package com.heima.user.feign;

import com.heima.apis.user.IUserClient;
import com.heima.model.user.pojos.ApUser;
import com.heima.user.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserClient implements IUserClient {

    @Autowired
    private UserService apUserService;

    /**
     * 获取用户名称
     * @param userId
     * @return
     */
    @PostMapping("/api/v1/getUserName")
    @Override
    public String getUserName(Integer userId) {
        return apUserService.getUserName(userId);
    }

    @Override
    @GetMapping("/api/v1/user/{id}")
    public ApUser findUserById(@PathVariable("id") Integer id) {
        return apUserService.getById(id);
    }
}
